package com.feicheng.iou.service.impl;

import com.feicheng.iou.pojo.ResultResourcePOJO;
import com.feicheng.iou.pojo.excelHandle.ExcelOutModel;
import com.feicheng.iou.service.ExcelOutMapperService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName ExcelServiceImpl
 * @Description 线索导出解析数据
 * @Author luoxin
 * @Date 2021/7/27 1:42 下午
 */
@Service
@Slf4j
public class ExcelServiceImpl implements ExcelOutMapperService {

    @Override
    public List<ExcelOutModel> parseResultResourcePOJO(List<ResultResourcePOJO> resultResourcePOJOList) {
        List<ExcelOutModel> excelModels = new ArrayList<>();

        for (ResultResourcePOJO resultResourcePOJO : resultResourcePOJOList) {
            ExcelOutModel excelModel = new ExcelOutModel();
            excelModel.setDegree(resultResourcePOJO.getStudent().getDegree());
            excelModel.setMajor(resultResourcePOJO.getStudent().getMajor());
            DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
            if(resultResourcePOJO.getStudent().getGraduateTime() != null) {
                String localTime = df.format(resultResourcePOJO.getStudent().getGraduateTime());
                excelModel.setGraduateTime(localTime);
            }
            excelModel.setGraduate(resultResourcePOJO.getStudent().getGraduate());
            excelModel.setName(resultResourcePOJO.getStudent().getName());
            excelModel.setCsgz(resultResourcePOJO.getResource().getCsgz());
            excelModel.setStatu(resultResourcePOJO.getResource().getStatu());
            excelModel.setBz(resultResourcePOJO.getResource().getBz());
            excelModel.setSource(resultResourcePOJO.getResource().getSource());
            excelModel.setTdgsmc(resultResourcePOJO.getResource().getTdgsmc());
            excelModel.setTel(resultResourcePOJO.getStudent().getTel());
            excelModel.setYpzw(resultResourcePOJO.getResource().getYpzw());
            excelModels.add(excelModel);
        }
        return excelModels;
    }
}
